﻿using System;

namespace DimensionsHelper.Common.Metadata;

public readonly struct MetadataContextLanguageKey : IEquatable<MetadataContextLanguageKey>
{
    private MetadataContextLanguageKey(string context, string language, string labelType)
    {
        Context = context.ToUpper();
        Language = language.ToUpper();
        LabelType = labelType.ToUpper();
    }


    private string Context { get; }

    private string Language { get; }

    private string LabelType { get; }


    public static MetadataContextLanguageKey Create(string context, string language, string labelType)
    {
        return new MetadataContextLanguageKey(context, language, labelType);
    }


    public bool Equals(MetadataContextLanguageKey other)
    {
        return other.Context.Equals(Context, StringComparison.OrdinalIgnoreCase) &&
               other.Language.Equals(Language, StringComparison.OrdinalIgnoreCase) &&
               other.LabelType.Equals(LabelType, StringComparison.OrdinalIgnoreCase);
    }

    public override bool Equals(object? obj)
    {
        return obj is MetadataContextLanguageKey key && Equals(key);
    }

    public static bool operator ==(MetadataContextLanguageKey left, MetadataContextLanguageKey right)
    {
        return left.Equals(right);
    }

    public static bool operator !=(MetadataContextLanguageKey left, MetadataContextLanguageKey right)
    {
        return !(left == right);
    }

    public override int GetHashCode()
    {
        return HashCode.Combine(Context, Language);
    }
}